package zl.ioc_and_factory;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

/**
 * @author  SuperZL 
 * @version 2012-8-29 下午3:47:38
 */
public class Test {
	
	public static void main(String[] args) throws FileNotFoundException, IOException{
		//普通工厂方式得到实例
		Animal animal = AnimalFactory1.createAnimal("Dog");
		System.out.print("Factory1+\t");
		animal.sayHello();
		//简单工厂方式得到实例
		animal = AnimalFactory2.createAnimal("zl.ioc_and_factory.Person");
		System.out.print("Factory2+\t");
		animal.sayHello();
		//根据XML配置文件得到实例
		Properties p = new Properties();
		p.loadFromXML(Test.class.getResourceAsStream("/"+File.separator+"animal-conf.xml"));
		animal = AnimalFactory2.createAnimal(p.getProperty("Dog"));
		System.out.print("Factory2增强版+\t");
		animal.sayHello();
	}
}
